#!/usr/bin/env bash
# Copyright (c) 2020 The Toltec Contributors
# SPDX-License-Identifier: MIT

pkgnames=(fbink fbdepth fbink-doom)
url=https://github.com/NiLuJe/FBInk
pkgver=1.25.0-1
timestamp=2022-12-05T02:50:38Z
maintainer="Mattéo Delabre <spam@delab.re>"
license=GPL-3.0
installdepends=(display)
flags=(patch_rm2fb)

image=base:v2.1

prepare() {
    git clone --depth=1 --recurse-submodules --branch v${pkgver%-*} https://github.com/NiLuJe/FBInk.git "$srcdir"/FBInk
}

build() {
    pushd FBInk
    REMARKABLE=1 make remarkable
    REMARKABLE=1 make fbdepth
    REMARKABLE=1 make utils
    popd
}

fbink() {
    pkgdesc="Print text and images to the framebuffer"
    section="devel"

    package() {
        install -D -m 755 -t "$pkgdir"/opt/bin "$srcdir"/FBInk/Release/fbink
    }
}

fbdepth() {
    pkgdesc="Change rotation and bitdepth of the screen"
    section="utils"

    package() {
        install -D -m 755 -t "$pkgdir"/opt/bin "$srcdir"/FBInk/Release/fbdepth
    }
}

fbink-doom() {
    pkgdesc="Doom fire effect stress test"
    section="utils"

    package() {
        install -D -m 755 -t "$pkgdir"/opt/bin "$srcdir"/FBInk/Release/doom
    }
}
